﻿using System;
using System.Web;
using Framework;

namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 添加产品分类
    /// </summary>
    public partial class AddProductCategory : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            object result;
            try
            {
                var file = Request.Files["Filedata"];
                if (file == null)
                {
                    result = (new { state = false, message = "上传图片不能为空！" });
                }
                else
                {
                    var filedata = new HttpPostedFileWrapper(Request.Files["Filedata"]);
                    var name = Fq("CoName");
                    var sorts = Fq("CoSort").SafeToInt();
                    var parentId = Fq("CoParentId").SafeToInt();
                    var nameEn = Fq("CoNameEn");

                    var productCategoryService = new ProductCategoryService();
                    productCategoryService.Add(name, nameEn, parentId, sorts, filedata);
                    result = new { state = true, message = "添加成功" };
                }

            }
            catch (Exception ex)
            {
                result = new { state = false, message = ex.Message };
            }
            Response.Write(result.Serialization());
            Response.End();



        }
    }
}